//
//  SAPAudioCollectionViewCell.m
//  CarsHome
//
//  Created by dapeng on 15/12/16.
//  Copyright © 2015年 dapeng. All rights reserved.
//

#import "SAPAudioCollectionViewCell.h"

@implementation SAPAudioCollectionViewCell
//- (void)dealloc {
//    [_album_name release];
//    [_imageViews release];
//    [_update_time release];
//    [super dealloc];
//}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.imageViews = [[UIImageView alloc] init];
        self.album_name = [[UILabel alloc] init];
        self.update_time = [[UILabel alloc] init];
        [_imageViews release];
        [_album_name release];
        [_update_time release];
        [self addSubview:self.imageViews];
        [self addSubview:self.album_name];
        [self addSubview:self.update_time];
        [_update_time release];
        [_album_name release];
        [_imageViews release];
    }return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    self.imageViews.frame = CGRectMake(20, 20, SCREEN_SIZE.width / 3 - 40, SCREEN_SIZE.width / 3 - 40);
    self.album_name.frame = CGRectMake(20, SCREEN_SIZE.width / 3 - 15, SCREEN_SIZE.width / 3 - 40, 20);
    self.update_time.frame = CGRectMake(20, SCREEN_SIZE.width / 3 + 5, SCREEN_SIZE.width / 3 - 40, 15);
    
}

- (void)setTwoModel:(SAPAudioTwoModel *)twoModel {
    if (_twoModel != twoModel) {
        [_twoModel release];
        _twoModel = [twoModel retain];
    }
    [self.imageViews sd_setImageWithURL:[NSURL URLWithString:twoModel.album_imgurl]];
    self.imageViews.layer.cornerRadius = (SCREEN_SIZE.width / 3 - 40) / 2;
    self.imageViews.layer.masksToBounds = YES;
    
    self.album_name.text = twoModel.album_name;
    self.album_name.textAlignment = NSTextAlignmentCenter;
    
    
    self.update_time.text = twoModel.update_time;
    self.update_time.font = [UIFont systemFontOfSize:12];
    self.update_time.textColor = [UIColor grayColor];
    self.update_time.textAlignment = NSTextAlignmentCenter;
    
}
@end
